package com.freewater.springboot.demo.testexecutionevents;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener;

@Slf4j
public class AggressiveLoadApplicationContext extends AbstractTestExecutionListener implements Ordered {

    @Override
    public int getOrder() {
        // 插入到EventPublishingTestExecutionListener之前, 提前初始化ApplicationContext，
        // 使得 ApplicationContext存在，能够发布BeforeTestClassEvent事件
        return 9999;
    }

    @Override
    public void beforeTestClass(TestContext testContext) {
        testContext.getApplicationContext();
    }
}
